package top.ucat.boots.example.rocketmq.provider.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Service;
import top.ucat.boots.example.rocketmq.provider.config.MySource;

/**
 * @Auther: Jun
 * @Date: 2019/8/21 15:26
 * @Description:
 */
@Service
public class SendService {

    @Autowired
    private MySource mySource;

    public void send(String message) {
        mySource.output().send(MessageBuilder.withPayload(message).build());
    }

    @StreamListener("input")
    public void receiveInput(String message) {
        System.out.println("Receive input: " + message);
    }
}
